local hx__jianqi = fk.CreateSkill {

  name = "hx__jianqi",

  tags = {  },

}



hx__jianqi:addEffect("active", {
  name = "hx__jianqi",
  anim_type = "support",
  can_use = function (self, player)
    return player:getMark("@hx__jianqi") > 0
  end,
  card_num = 0,
  card_filter = Util.FalseFunc,
  target_num = 1,
  target_filter = function (self, player, to_select, selected, selected_cards)
    return #selected == 0 
  end,
  on_use = function (self, room, effect)
    local player = effect.from
    local target = effect.tos[1]
    room:removePlayerMark(player,"@hx__jianqi",1)
    room:recover{
      who = player,
      num = 1,
      skillName = hx__jianqi.name,
      recoverBy = player,
    }
    room:setPlayerMark(target,"@hx__jianqi__recover-turn","hx__jianqi__canrecover")
  end,
})

hx__jianqi:addEffect(fk.DamageCaused, {
  name = "#hx__jianqi__trigger",
  anim_type = "support",
  can_trigger = function (self, event, target, player, data)
    return player:hasSkill("hx__jianqi") and target and target == player and data.to:getMark("@hx__jianqi__recover-turn") == "hx__jianqi__canrecover"
  end,
  on_cost = Util.TrueFunc,
  on_use = function (self, event, target, player, data)
    local room = player.room
    room:recover{
      who = player,
      num = data.damage,
      recoverBy = player,
      skillName = hx__jianqi.name,
    }
  end,
})

return hx__jianqi